/*
Picture
Give you the width and height of the rectangle,darw it.
Input
Input contains a number of test cases.For each case ,there are two numbers n and m (0 < n,m < 75)indicate the width and height of the rectangle.Iuput ends of EOF.
Output
For each case,you should draw a rectangle with the width and height giving in the input. 
after each case, you should a blank line.
Sample Input
3 2
Sample Output
+---+
|   |
|   |
+---+
*/
#include <bits/stdc++.h>
#define ll long long
#define PI acos(-1)
#define M(n, m) memset(n, m, sizeof(n));
const int INF = 1e9 + 7;
const int maxn = 1e5;
using namespace std;

int main()
{
    int n, m;
    while(cin >> m >> n)
    {
        for (int i = 0; i <= m + 1; i ++)
            if (i == 0 || i == (m + 1))
                cout << "+";
            else
                cout << "-";
        cout << endl;

        for (int i = 0; i < n; i ++, cout << endl)
            for (int j = 0; j <= m + 1; j ++)
                if (j == 0 || j == (m + 1))
                    cout << "|";
                else
                    cout << " ";

        for (int i = 0; i <= m + 1; i ++)
            if (i == 0 || i == (m + 1))
                cout << "+";
            else
                cout << "-";
        cout << endl;

        cout << endl;
    }
    return 0;
}
